<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改【请填写功能名称】')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-nowork-edit" th:object="${qServiceNowork}">
            <input name="serviceId" th:field="*{serviceId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">服务会话Id：</label>
                <div class="col-sm-8">
                    <input name="serviceId" th:field="*{serviceId}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">开始时间：</label>
                <div class="col-sm-8">
                    <input name="beginTime" th:field="*{beginTime}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">结束时间：</label>
                <div class="col-sm-8">
                    <input name="endTime" th:field="*{endTime}" class="form-control" type="text">
                </div>
            </div>



            <div class="form-group">
                <label class="col-sm-3 control-label">坐席客服名称：</label>
                <div class="col-sm-8">
                    <input name="agentid" th:field="*{agentid}" class="form-control" disabled type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">客户号码：</label>
                <div class="col-sm-8">
                    <input name="fromnum" th:field="*{fromnum}" class="form-control" disabled type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">全局录音：</label>
                <div class="col-sm-8">

                    <input id="serviceId" type="hidden" name="serviceId" th:field="*{serviceId}">
                    <input id="voxfile" type="hidden" name="voxfile" th:field="*{voxfile}">
                    <audio id="myAudio" controls>
                        Your browser does not support the audio element.
                    </audio>
                </div>
            </div>

        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <th:block th:include="include :: summernote-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/nowork";
        $("#form-nowork-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-nowork-edit').serialize());
            }
        }

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': ctx + 'common/upload',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });

        $(function () {

            var audio = document.getElementById('myAudio');
            var voxfile = $("#voxfile").val();
            var serviceId = $("#serviceId").val();


            var v1 = 'https://zvoice.oss-cn-beijing.aliyuncs.com/rec' + voxfile + '.mp3';
            var v2 = 'http://111.22.175.38:10081/admin/api/recordplay.php?linkedid=' + serviceId;
            var myDate = new Date();
            myDate.setFullYear(2024, 7, 31);

            var recordTime = $("#beginTime").val();

            if (serviceId.length <= 20) {
                //
                audio.src = v1; // 这里的路径应该指向你的音频文件 7月以前的
                audio.load(); // 加载音频文件
                // audio.play(); // 播放音频
                console.log("Today is before 2024-7-31");
            } else {
                audio.src = v2; // 这里的路径应该指向你的音频文件
                audio.load(); // 加载音频文件
                //   audio.play(); // 播放音频
                console.log("Today is after 2024-7-31");
            }


        });
    </script>
</body>
</html>